﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Hasher
/// </summary>
public class Hasher
{
    public static string SHA256(byte[] a_hashMe)
    {
        string f_hashedString = "";
        using (System.Security.Cryptography.SHA256 hashAlgorithm = System.Security.Cryptography.SHA256.Create())
        {
            byte[] f_hash = hashAlgorithm.ComputeHash(a_hashMe);
            f_hashedString = GetHashString(f_hash);

            hashAlgorithm.Dispose();
        }

        return f_hashedString;
    }

    private static string GetHashString(byte[] a_hash)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        foreach (byte b in a_hash)
            sb.Append(b.ToString("X2"));

        return sb.ToString().ToLower();
    }
}